home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Programming / Stuart's Tech Notes / StUU / Sources / uudecode.doc < prev   
Encoding:
Text File  |  1995-01-07  |  14.9 KB  |  122 lines  |  [TEXT/R*ch]

  1.  
  2. Documentation for UUENCODE/DECODE 5.15
  3.  
  4. UU-encoding is a way to code a file which may contain any characters into a
  5. standard character set that can be reliably sent over diverse networks.
  6.  
  7.  
  8. THE CHARACTER ENCODING:
  9.  
  10. The basic scheme is to break groups of 3 eight bit characters (24 bits) into 4
  11. six bit characters and then add 32 (a space) to each six bit character which
  12. maps it into the readily transmittable character.  Another way of phrasing this
  13. is to say that the encoded 6 bit characters are mapped into the set:
  14.         `!"#$%&'()*+,-./012356789:;<=>?@ABC...XYZ[\]^_
  15. for transmission over communications lines.
  16.  
  17. As some transmission mechanisms compress or remove spaces, spaces are changed
  18. into back-quote characters (a 96).  (A better scheme might be to use a bias of
  19. 33 so the space is not created, but this is not done.)
  20.  
  21. Another newer less popular encoding method, called XX-encoding uses the set:
  22.         +-01..89ABC...XYZabc...xyz
  23.  
  24. In my opinion, XX-encoding is superior to UU-encoding because it uses more
  25. "normal" characters that are less likely to get corrupted.  In fact several of
  26. the special characters in the UU set do not get thru an EBCDIC to ASCII
  27. translation correctly.  Conversely, an advantage of the UU set is that it does
  28. not use lower case characters.  Now-a-days both upper and lower case are sent
  29. with no problems; maybe in the communications dark ages, there was a problem
  30. with lower case.
  31.  
  32. This "UU" encode/decode pair can handle either XX or UU encoding.  The encode
  33. program defaults to creating a UU encoded file; but can be run with a "-x"
  34. option to create an XX encoding.
  35.  
  36. The decode program defaults to autodetect.  However the program can get confused
  37. by comment lines preceeding the actual encoded data.  The decode mode can be
  38. forced to UU or XX with the "-u" or "-x" parameter.
  39.  
  40. Another option is for the character mapping table to be inserted at the front of
  41. the file.  The format for this is discussed later.  The table parameters are
  42. detected and used by this decode program.  (A table will override the "-x" or
  43. "-u" parameters.) The encode program can be run with a "-t" option which tells
  44. it to put the table into the encoded file.
  45.  
  46. A third encode mapping is the one used by Brad Templeton's ABE program.  This is
  47. not handled by these programs as the check and control information surrounding
  48. the actual encoded data is in a different form.
  49.  
  50. From a theoritical view, this encoding is breaking down 24 bits modulo 64.  Note
  51. that 64**3 is = 2**24.  The result is 24 bits in for 32 bits out, a 33% size
  52. increase.  Note that 85**5 > 2**32.  Also note that there are 94 transmittable
  53. ASCII characters (from 0x21 thru 0x7e).  Thus modulo 85 encoding (the atob
  54. encoder) transforms 32 bits to 5 ASCII chars or 40 bits for a 25% size increase.
  55.  
  56. The trade off in the module 85 encoding is that many communications systems do
  57. not reliably transmit 85 ASCII characters.  The tilda, carat, brackets, and
  58. sometimes upper or lower case frequently get corrupted.
  59.  
  60. COMPOSING A LINE OF ENCODED CHARACTERS:
  61.  
  62. A small number of eight bit characters are encoded into a single line and a
  63. count is put at the start of the line.  (Most lines in an encoded file have 45
  64. encoded characters.  When you look at a UU-encoded file note that most lines
  65. start with the letter "M".  "M" is decimal 77 which, minus the 32 bias, is 45.)
  66.  
  67. This encode program puts a check character at the end of each line.  The check
  68. is the sum of all the encoded characters, before adding the mapping, modulo 64.
  69.  
  70. Note: Horton 9/1/87 UUENCODE has a bug in the line check algorithm; it uses the
  71. sum of the original, not the encoded characters.  This decode program accepts
  72. either form of line check character.
  73.  
  74. In previous versions (4.13 and lower) the line check characters was generated by
  75. default by this encode program and was supressed with the "-L" option.  One
  76. reason to supress them is if they will be decoded by one of the old Horton
  77. decoders.  Most decoders either accept this form of check or simply stop looking
  78. after the line length is exhausted.  My feelings are mixed about the line
  79. checksums because errors of this type essentially never occur.
  80.  
  81. However with modern, error-free communications systems and with the CRC checks
  82. on the entire file (see below) I have made the default for uuencoding to have NO
  83. line level check characters effective version 4.21.  The "-L" option on uuencode
  84. turns on generation of line checksums.  If you have a really bad communications
  85. system and you want to isolate a problem, turn them on.
  86.  
  87. Uudecode automatically checks for the presense line checksums, so the default
  88. for uudecode is to leave line level checks on; if there are some problems the
  89. "-L" option for uudecode turns them off.  Sometimes there is junk at the end of
  90. the line which causes spurious line checksum errors.
  91.  
  92. I have encountered various other ways that encoders end lines.  One encoder put
  93. a "M" at both the start and end of the line.  Another used a line count
  94. character.  This decode program checks all of these.  I would not be surprised
  95. if some encoder out there ends lines with astrological symbols.  If you
  96. encounter some other wierd form of encoded file, let me know.
  97.  
  98.  
  99. PACKAGING THE LINES INTO FILES:
  100.  
  101. The lines of encoded data can be preceded by comments and by network addressing
  102. information.  The encoded data is directly preceded by a line containing:
  103.  
  104.              begin <file-mode> <file-name>
  105.  
  106. This line is created by the encoding program.  The decode program scans the file
  107. looking for "begin" in column 1.
  108.  
  109. The final end of encoded data is an encoded line with zero encoded characters (a
  110. back-quote), followed by a line containing "end".
  111.  
  112. For integrity checking, various encode programs insert checksums for the entire
  113. file.  This decode tries to check for all known types of file checksums.  This
  114. is discussed in more detail later.
  115.  
  116. This encode program puts a header line, containing the section number and file
  117. name, in front of every section:
  118.  
  119.          "section <number> of uuencode of file <file name>"
  120.  
  121. At the end of a section the encode program inserts a line containing checksum
  122. and file size information